#!/usr/bin/env python

"""
Lets get the print thing working
"""
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtWebKit as QtWebKit

import sys

class htmlViewer(QtWebKit.QWebView):
        def __init__(self,url, parent=None):
                QtWebKit.QWebView.__init__(self,parent)
                self.setUrl(QUrl(url))
                self.preview = QPrintPreviewDialog()
                self.connect(self.preview,SIGNAL("paintRequested (QPrinter *)"),SLOT("print (QPrinter *)"))
                self.connect(self,SIGNAL("loadFinished(bool)"),self.execpreview)
        def execpreview(self,arg):
                print arg
                self.preview.exec_()

if __name__=="__main__":
        app = QApplication(sys.argv)
        
        myurl = "http://www.google.com";
        widget = htmlViewer(myurl)
        widget.show()
                
        sys.exit(app.exec_())
